package com.hckj.jianzhijia;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVFile;
import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.AVQuery;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.RequestEmailVerifyCallback;
import com.hckj.jianzhijia.listeners.OnBackClickListener;
import com.hckj.jianzhijia.model.CompanyUser;
import com.hckj.jianzhijia.model.Identification;
import com.hckj.jianzhijia.popupwindows.GetIDCardPicBackPopWin;
import com.hckj.jianzhijia.popupwindows.GetIDCardPicFrontPopWin;
import com.hckj.jianzhijia.popupwindows.GetLicensePicPopWin;
import com.hckj.jianzhijia.utils.BitmapUtils;
import com.hckj.jianzhijia.utils.Data;
import com.hckj.jianzhijia.utils.ExceptionUtils;
import com.hckj.jianzhijia.utils.IDCardUtils;
import com.hckj.jianzhijia.utils.ToastUtils;
import com.rey.material.app.Dialog;
import com.rey.material.app.DialogFragment;
import com.rey.material.app.SimpleDialog;
import com.rey.material.widget.CheckBox;
import com.rey.material.widget.RadioButton;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.UUID;

import butterknife.ButterKnife;
import butterknife.InjectView;

//认证协议,从数据库中获取到相关认证信息

public class IdentificationActivity extends BaseActivity implements GetLicensePicPopWin.PopWinInterface,
                                                                                GetIDCardPicBackPopWin.PopWinInterface,
                                                                                GetIDCardPicFrontPopWin.PopWinInterface {


    @InjectView(R.id.imgv_go_back)
    ImageView imgvGoBack;
    @InjectView(R.id.rl_toolbar)
    RelativeLayout rlToolbar;
    @InjectView(R.id.sw_company_identification)
    RadioButton swCompanyIdentification;
    @InjectView(R.id.sw_school_identification)
    RadioButton swSchoolIdentification;
    @InjectView(R.id.tv_company_name)
    TextView tvCompanyName;
    @InjectView(R.id.imgv_up_down_arrow)
    ImageView imgvUpDownArrow;
    @InjectView(R.id.rl_show_info)
    RelativeLayout rlShowInfo;
    @InjectView(R.id.tv_email)
    TextView tvEmail;
    @InjectView(R.id.rl_email)
    LinearLayout rlEmail;
    @InjectView(R.id.tv_address)
    TextView tvAddress;
    @InjectView(R.id.rl_address)
    LinearLayout rlAddress;
    @InjectView(R.id.tv_desc)
    TextView tvDesc;
    @InjectView(R.id.rl_desc)
    LinearLayout rlDesc;
    @InjectView(R.id.ll_info)
    LinearLayout llInfo;
    @InjectView(R.id.edt_contact_people)
    EditText edtContactPeople;
    @InjectView(R.id.edt_contact_phone)
    EditText edtContactPhone;
    @InjectView(R.id.edt_id_card)
    EditText edtIdCard;
    @InjectView(R.id.edt_license_id)
    EditText edtLicenseId;
    @InjectView(R.id.tv_id_card_1)
    TextView tvIdCard1;
    @InjectView(R.id.imgv_id_card_1)
    ImageView imgvIdCard1;
    @InjectView(R.id.tv_id_card_2)
    TextView tvIdCard2;
    @InjectView(R.id.imgv_id_card_2)
    ImageView imgvIdCard2;
    @InjectView(R.id.tv_license)
    TextView tvLicense;
    @InjectView(R.id.imgv_license)
    ImageView imgvLicense;
    @InjectView(R.id.cb_read_protocol)
    CheckBox cbReadProtocol;
    @InjectView(R.id.tv_read_protocol)
    TextView tvReadProtocol;
    @InjectView(R.id.btn_confirm)
    Button btnConfirm;
    @InjectView(R.id.imgv_email_warning)
    ImageView imgvEmailWarning;
    @InjectView(R.id.imgv_people_list)
    ImageView imgvPeopleList;
    @InjectView(R.id.tv_letter_desc)
    TextView tvLetterDesc;
    @InjectView(R.id.tv_company_school_num)
    TextView tvCompanySchoolNum;

    private static final int SELECT_CONTACTOR_CODE = 1234;
    @InjectView(R.id.ll_parent)
    LinearLayout llParent;
    private Identification identification;
    private boolean infoShow = false;
    private ProgressDialog progressDialog;
    private GetIDCardPicBackPopWin getIDCardPicBackPopWin;
    private GetIDCardPicFrontPopWin getIDCardPicFrontPopWin;
    private GetLicensePicPopWin getLicensePicPopWin;
    private int picType = 0;

    private int state = Identification.STATE_ING;
    private int identificationType = Identification.TYPE_COMPANY;
    private String picTempFile = Data.sdpath + "pic";

    private String contactPersonName;
    private String contactPhone;
    private AVFile licensePic;
    private String licenseNum;
    private String IDCardNum;
    private AVFile peopleIDCard1;
    private AVFile peopleIDCard2;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_identification);
        ButterKnife.inject(this);
        progressDialog = new ProgressDialog(this);
        progressDialog.setMessage("正在加载中");
        progressDialog.setCancelable(false);
        GetIdentificationInfoTask getIdentificationInfoTask = new GetIdentificationInfoTask();
        getIdentificationInfoTask.execute();
        initData();
        initEvent();
        initPopupWin();
    }

    private void initPopupWin() {
        getIDCardPicBackPopWin = new GetIDCardPicBackPopWin(this,this,llParent,imgvIdCard2);
        getIDCardPicFrontPopWin = new GetIDCardPicFrontPopWin(this,this,llParent,imgvIdCard1);
        getLicensePicPopWin = new GetLicensePicPopWin(this,this,llParent,imgvLicense);
    }

    private void initData() {

        CompanyUser companyUser = jianzhijiaApplacation.getCompanyUser();
        tvCompanyName.setText(companyUser.getName());
        tvEmail.setText(companyUser.getEmail());
        tvAddress.setText(companyUser.getProvinceName() +
                                      companyUser.getCityName() +
                                      companyUser.getRegionName() +
                                      companyUser.getCompanyAddress());
        tvDesc.setText(companyUser.getDescription());

        if (companyUser.isEmailVerified()) {
            imgvEmailWarning.setVisibility(View.GONE);
        } else {
            imgvEmailWarning.setVisibility(View.VISIBLE);
        }


    }

    private void initEvent() {
        //返回按钮监听
        imgvGoBack.setOnClickListener(new OnBackClickListener(this));
        //初始化RadioButton控件
        CompoundButton.OnCheckedChangeListener listener = new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    if (swCompanyIdentification == buttonView) {//企业认证
                        swCompanyIdentification.setChecked(true);
                        swSchoolIdentification.setChecked(false);
                        tvCompanySchoolNum.setText("执照编号");
                        edtLicenseId.setHint("请输入企业的营业执照编号");
                        tvLetterDesc.setText("照片上传：1.身份证正面照 2.身份证反面照 3.企业公函照片");
                        tvLicense.setText("企业公函照片");
                        identificationType = Identification.TYPE_COMPANY;

                    } else if (swSchoolIdentification == buttonView) {
                        swCompanyIdentification.setChecked(false);
                        swSchoolIdentification.setChecked(true);
                        tvCompanySchoolNum.setText("学校编号");
                        edtLicenseId.setHint("请输入国家指定的学校编号");
                        tvLetterDesc.setText("照片上传：1.身份证正面照 2.身份证反面照 3.学校公函照片");
                        tvLicense.setText("学校公函照片");
                        identificationType = Identification.TYPE_SCHOOL;
                    }


                }
            }
        };
        swCompanyIdentification.setOnCheckedChangeListener(listener);
        swSchoolIdentification.setOnCheckedChangeListener(listener);

        //初始化点击显示控件
        rlShowInfo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (infoShow) {
                    llInfo.setVisibility(View.GONE);
                    imgvUpDownArrow.setImageResource(R.drawable.icon_down);
                    infoShow = false;
                } else {
                    llInfo.setVisibility(View.VISIBLE);
                    imgvUpDownArrow.setImageResource(R.drawable.icon_up);
                    infoShow = true;
                }
            }
        });


        tvEmail.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                // TODO: 2015-12-02 修改邮箱操作
                String content = jianzhijiaApplacation.getCompanyUser().getEmail();
                showMaterialDialog(content, "您的邮箱", new DialogAction() {
                    @Override
                    public void positiveAction() {

                    }

                    @Override
                    public void negativeAction() {

                    }
                });
            }
        });

        tvAddress.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO: 2015-12-02 修改地址操作
                CompanyUser companyUser = jianzhijiaApplacation.getCompanyUser();
                String content = companyUser.getProvinceName() +
                                             companyUser.getCityName() +
                                             companyUser.getRegionName() +
                                             companyUser.getCompanyAddress();
                showMaterialDialog(content, "您的机构地址", new DialogAction() {
                    @Override
                    public void positiveAction() {

                    }

                    @Override
                    public void negativeAction() {

                    }
                });
            }
        });


        tvDesc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO: 2015-12-02 修改简介操作
                CompanyUser companyUser = jianzhijiaApplacation.getCompanyUser();
                String content = companyUser.getDescription();
                showMaterialDialog(content, "您的机构简介", new DialogAction() {
                    @Override
                    public void positiveAction() {

                    }

                    @Override
                    public void negativeAction() {

                    }
                });
            }
        });

        imgvEmailWarning.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               final  CompanyUser companyUser = jianzhijiaApplacation.getCompanyUser();
                if (companyUser.isIdentified()) {
                    return;
                } else {
                    String content = "您的邮箱  " + companyUser.getEmail() + "  尚未验证,是否进行验证操作";
                    showMaterialDialog(content, "邮箱未验证", new DialogAction() {
                        @Override
                        public void positiveAction() {

                            progressDialog.setMessage("正在上传");
                            progressDialog.show();
                            AVUser.requestEmailVerfiyInBackground(companyUser.getEmail(), new RequestEmailVerifyCallback() {
                                @Override
                                public void done(AVException e) {
                                    if(e == null){
                                        progressDialog.dismiss();
                                        String content = "已向您的邮箱发送了一份验证邮件，请登录邮箱进行验证";
                                        showMaterialDialog(content, "邮箱验证", new DialogAction() {
                                            @Override
                                            public void positiveAction() {

                                            }

                                            @Override
                                            public void negativeAction() {

                                            }
                                        });



                                    }else {
                                        progressDialog.dismiss();
                                        ToastUtils.showToast(getApplicationContext(),ExceptionUtils.getExceptionInfo(e));
                                    }
                                }
                            });

                        }

                        @Override
                        public void negativeAction() {

                        }
                    });
                }
            }
        });


        imgvPeopleList.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
                startActivityForResult(i, SELECT_CONTACTOR_CODE);
            }
        });

        tvLetterDesc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (swCompanyIdentification.isChecked()) {
                    return;
                } else {
                    Intent intent = new Intent(getApplicationContext(), WebPageActivity.class);
                    intent.putExtra("WebPageType", WebPageActivity.WEBPAGE_LETTER);
                    startActivity(intent);
                }
            }
        });



        tvReadProtocol.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getApplicationContext(), WebPageActivity.class);
                intent.putExtra("WebPageType", WebPageActivity.WEBPAGE_IDNTIFICATION);
                startActivity(intent);
            }
        });

        btnConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getAllData();
                if(!checkData()){
                    return ;
                }else{
                    GetIdentificationInfoNetTask getIdentificationInfoNetTask = new GetIdentificationInfoNetTask();
                    getIdentificationInfoNetTask.execute();
                }
            }
        });


    }

    private boolean checkData() {

        if(contactPersonName == null || contactPersonName.equals("")){
            ToastUtils.showToast(getApplicationContext(),"联系人姓名不能为空");
            return false;
        }else if(contactPhone == null || contactPhone.equals("")){
            ToastUtils.showToast(getApplicationContext(),"联系电话不能为空");
            return false;
        }else if(null == IDCardNum || IDCardNum.equals("")){
            ToastUtils.showToast(getApplicationContext(),"身份证号码不能为空");
            return false;
        }else if(!IDCardUtils.validateCard(IDCardNum)){
            ToastUtils.showToast(getApplicationContext(),"身份证号码格式错误");
            return false;
        }else if(licenseNum == null || licenseNum.equals("")) {
            if(identificationType == Identification.TYPE_COMPANY){
                ToastUtils.showToast(getApplicationContext(),"执照编号不能为空");
            }else{
                ToastUtils.showToast(getApplicationContext(),"学校编号不能为空");
            }
            return false;
        }else if(licensePic == null){
            ToastUtils.showToast(getApplicationContext(),"照片不能为空");
            return false;
        }else if(peopleIDCard1 == null){
            ToastUtils.showToast(getApplicationContext(),"照片不能为空");
            return false;
        }else if(peopleIDCard2 == null){
            ToastUtils.showToast(getApplicationContext(),"照片不能为空");
            return false;
        }else if(!cbReadProtocol.isChecked()){
            ToastUtils.showToast(getApplicationContext(),"请阅读认证协议");
            return false;
        }
        return true;
    }


//    private void showMaterialDialog(String content, String title, final DialogAction dialogAction) {
//
//        Dialog.Builder builder = null;
//        builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {
//            @Override
//            public void onPositiveActionClicked(DialogFragment fragment) {
//                fragment.dismiss();
//                dialogAction.positiveAction();
//                super.onPositiveActionClicked(fragment);
//            }
//
//            @Override
//            public void onNegativeActionClicked(DialogFragment fragment) {
//                fragment.dismiss();
//                dialogAction.negativeAction();
//                super.onNegativeActionClicked(fragment);
//            }
//        };
//
//        ((SimpleDialog.Builder) builder).message(content)
//                    .positiveAction("确认")
//                    .negativeAction("取消").title(title);
//        DialogFragment fragment = DialogFragment.newInstance(builder);
//        fragment.setCancelable(false);
//        fragment.show(getSupportFragmentManager(), null);
//    }


    class GetIdentificationInfoNetTask extends AsyncTask<Void, Void, String> {

        @Override
        protected void onPreExecute() {
            progressDialog.setMessage("正在上传");
            progressDialog.show();
            super.onPreExecute();
        }

        @Override
        protected void onPostExecute(String s) {
            progressDialog.dismiss();
            ToastUtils.showToast(getApplicationContext(), s);
            finish();
            startActivity(new Intent(getApplicationContext(),WaitingIdentificationActivity.class));
            super.onPostExecute(s);
        }

        @Override
        protected String doInBackground(Void... params) {


            try {
                licensePic.save();
                peopleIDCard1.save();
                peopleIDCard2.save();
                identification = new Identification();
                identification.setUser(jianzhijiaApplacation.getCompanyUser().getAvUser());
                identification.setContactPersonName(contactPersonName);
                identification.setContactPhone(contactPhone);
                identification.setIdentificationType(identificationType);
                identification.setLicensePic(licensePic);
                identification.setLicenseNum(licenseNum);
                identification.setPeopleIDCard1(peopleIDCard1);
                identification.setPeopleIDCard2(peopleIDCard2);
                identification.setState(state);
                identification.setIDCardNum(IDCardNum);
                identification.getIdentification().save();
                return "上传成功";
            } catch (AVException e) {
                e.printStackTrace();
                return "上传失败 " + ExceptionUtils.getExceptionInfo(e);
            }

        }
    }


    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == SELECT_CONTACTOR_CODE && resultCode == RESULT_OK && data != null) {
            Uri resultUri = data.getData();
            Cursor cursor = getContentResolver().query(resultUri, null, null, null, null);
            cursor.moveToFirst();
            String transCustomorName = null;
            String transCustomorPhone = null;
            try {
                transCustomorPhone = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER));
                transCustomorName = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
                ToastUtils.showToast(getApplicationContext(), "读取联系人失败，请手动输入");
                return;
            }
            if (transCustomorPhone != null) {
                edtContactPhone.setText(transCustomorPhone);
            }
            if (transCustomorName != null) {
                edtContactPeople.setText(transCustomorName);
            }
            return ;
        }

        Bitmap bitmap = null;

        if (requestCode == MainActivity.GET_PHOTO && resultCode == Activity.RESULT_OK) {
            bitmap =  BitmapUtils.compressImage(BitmapUtils.compressImageFromFile(picTempFile),500);
        } else if (data != null && requestCode == MainActivity.CHOOSE_PHOTO && resultCode == Activity.RESULT_OK) {
            Uri originalUri = data.getData();
            Cursor cursor = managedQuery(originalUri, new String[]{MediaStore.Images.Media.DATA}, null, null, null);
            int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            cursor.moveToFirst();
            String path = cursor.getString(column_index);
            bitmap =  BitmapUtils.compressImage(BitmapUtils.compressImageFromFile(path),500);
        }
        if(bitmap==null){
            return ;
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        switch (picType){
            case 1:
                imgvIdCard1.setImageBitmap(bitmap);
                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
                peopleIDCard1 = new AVFile("peopleIDCard1" + jianzhijiaApplacation.getCompanyUser().getPhone(), baos.toByteArray());
                break;
            case 2:
                imgvIdCard2.setImageBitmap(bitmap);
                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
                peopleIDCard2 = new AVFile("peopleIDCard2" + jianzhijiaApplacation.getCompanyUser().getPhone(), baos.toByteArray());
                break;
            case 3:
                imgvLicense.setImageBitmap(bitmap);
                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
                licensePic = new AVFile("licensePic" + jianzhijiaApplacation.getCompanyUser().getPhone(), baos.toByteArray());
                break;
        }
    }

    @Override
    public void modifyFromPhotoLicense(int position) {
        picType = 3;
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);//调用android自带的照相机
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(picTempFile)));
        startActivityForResult(intent, MainActivity.GET_PHOTO);
    }

    @Override
    public void modifyFromPhotoIDCardFront(int position) {
        picType = 1;
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);//调用android自带的照相机
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(picTempFile)));
        startActivityForResult(intent, MainActivity.GET_PHOTO);
    }

    @Override
    public void modifyFromPhotoIDCardBack(int position) {
        picType = 2;
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);//调用android自带的照相机
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(picTempFile)));
        startActivityForResult(intent, MainActivity.GET_PHOTO);
    }

    @Override
    public void modifyFromAlbumIDCardBack(int position) {
        picType = 2;
        Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
        intent.putExtra("return-data", true);
        startActivityForResult(intent, MainActivity.CHOOSE_PHOTO);
    }

    @Override
    public void modifyFromAlbumLicense(int position) {
        picType = 3;
        Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
        intent.putExtra("return-data", true);
        startActivityForResult(intent, MainActivity.CHOOSE_PHOTO);
    }

    @Override
    public void modifyFromAlbumIDCardFront(int position) {
        picType = 1;
        Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
        intent.putExtra("return-data", true);
        startActivityForResult(intent, MainActivity.CHOOSE_PHOTO);
    }


    private void getAllData(){
        contactPersonName = edtContactPeople.getText().toString().trim();
        contactPhone = edtContactPhone.getText().toString().trim();
        IDCardNum = edtIdCard.getText().toString().trim();
        licenseNum = edtLicenseId.getText().toString().trim();
    }


    class GetIdentificationInfoTask extends AsyncTask<Void,Void,String>{

        Identification identification;
        @Override
        protected String doInBackground(Void... params) {
            AVQuery avQuery = new AVQuery(Identification.TABLE_NAME);
            avQuery.whereEqualTo("user",jianzhijiaApplacation.getCompanyUser().getAvUser());
            avQuery.orderByDescending("createdAt");
            try {
                List list = avQuery.find();
                if(list.size()==0){
                    return "尚未认证";
                }else{
                    AVObject avObject = (AVObject) list.get(0);
                    identification = new Identification(avObject);
                    if(identification.getState() == Identification.STATE_FAIL){
                        return "认证失败";
                    }else if(identification.getState() == Identification.STATE_ING){
                        return "认证审核中";
                    }else{
                        return "认证成功";
                    }
                }
            } catch (AVException e) {
                e.printStackTrace();
                return ExceptionUtils.getExceptionInfo(e);
            }
        }

        @Override
        protected void onPreExecute() {
            progressDialog.setMessage("正在加载");
            progressDialog.show();
            super.onPreExecute();
        }

        @Override
        protected void onPostExecute(String s) {
            progressDialog.dismiss();
            String content = null;
            if(s.equals("尚未认证")){
                return ;
            }else if(s.equals("认证失败")){
                content = "您的账号认证失败，失败原因：" + identification.getFailReason() + "请您重新认证";
                showMaterialDialog(content, s, new DialogAction() {
                    @Override
                    public void positiveAction() {

                    }

                    @Override
                    public void negativeAction() {
                        finish();
                    }
                });

            }else if(s.equals("认证审核中")){
                content = "您的账号正在审核中，管理员将尽快为您进行审核，请您稍等...";
                showMaterialDialog(content, s, new DialogAction() {
                    @Override
                    public void positiveAction() {
                        finish();
                    }

                    @Override
                    public void negativeAction() {
                        finish();
                    }
                });

            }else if(s.equals("认证成功")){
                content = "您的账号已经认证过了，无需再进行认证，请您重新登录";
                showMaterialDialog(content, s, new DialogAction() {
                    @Override
                    public void positiveAction() {
                        finish();
                    }

                    @Override
                    public void negativeAction() {
                        finish();
                    }
                });
            }else{
                ToastUtils.showToast(getApplicationContext(),s);
                finish();
            }
            super.onPostExecute(s);
        }
    }
}
